﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace IBLL
{
    public interface IBaseBLL<T>
    {
        /// <summary>
        /// 新增实体
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        int ADD(T model);

        /// <summary>
        /// 根据ID 删除
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        int Del(T model);

        /// <summary>
        /// 根据条件删除 
        /// </summary>
        /// <param name="delwhere"></param>
        /// <returns></returns>
        int DelByWhere(Expression<Func<T, bool>> delwhere);

        /// <summary>
        /// 修改 
        /// T Modify_eg =new T(){ ID_eg = 1,Name_eg = "valeb" };
        ///  this.Modify( Modify_eg, "Name_eg");
        /// </summary>
        /// <param name="model">要修改的  实体对象</param>
        /// <param name="ProNames">要修改的  属性 名称</param>
        /// <returns></returns>
        int Modify(T model, params string[] ProNames);

        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="model">要修改的  实体对象</param>
        /// <param name="whereLambda">查询 条件</param>
        /// <param name="ModifiedProNames">要修改的 属性名称</param>
        /// <returns></returns>
        int Modify(T model, Expression<Func<T, bool>> whereLambda, params string[] ModifiedProNames);

        /// <summary>
        /// 根据条件查询
        /// </summary>
        /// <param name="whereLambda">查询条件</param>
        /// <returns></returns>
        List<T> GetListByWhere(Expression<Func<T, bool>> whereLambda);

        /// <summary>
        /// 根据条件  排序 查询
        /// </summary>
        /// <typeparam name="K">排序字段类型</typeparam>
        /// <param name="whereLambda">查询条件  Lambda 表达式</param>
        /// <param name="orderLambda">排序条件  Lambda 表达式</param>
        /// <returns></returns>
        List<T> GetListByWhere<K>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, K>> orderLambda);

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <typeparam name="K">排序字段类型</typeparam>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页容量</param>
        /// <param name="whereLambda">查询条件 Lambda 表达式</param>
        /// <param name="orderLambda">排序条件 Lambda 表达式</param>
        /// <returns></returns>
        List<T> GetPageList<K>(int pageIndex,int pageSize,Expression<Func<T,bool>> whereLambda,Expression<Func<T,K>> orderLambda);

        /// <summary>
        /// 分页查询 输出总行数据
        /// </summary>
        /// <typeparam name="K"></typeparam>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="rowCount">总行数据</param>
        /// <param name="whereLambda"></param>
        /// <param name="orderBy"></param>
        /// <param name="isAsc"></param>
        /// <returns></returns>
        List<T> GetPagedList<K>(int pageIndex, int pageSize, ref int rowCount, Expression<Func<T, bool>> whereLambda, Expression<Func<T, K>> orderBy, bool isAsc = true);

        /// <summary>
        /// 执行sql语句
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="paras"></param>
        /// <returns></returns>
        int ExcuteSql(string strSql, params object[] paras);

        /// <summary>
        /// 查询sql语句
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="strSql"></param>
        /// <param name="paras"></param>
        /// <returns></returns>
        List<T> SqlQuery<T>(string strSql, params object[] paras);
    }



}
